package org.example.thread;

import org.apache.tomcat.util.threads.ThreadPoolExecutor;

import java.util.concurrent.*;

public class CompleTableFutureDemo02 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService =
                new ThreadPoolExecutor(8,16,30000, TimeUnit.MILLISECONDS,
                        new LinkedBlockingQueue<>(100),new ThreadPoolExecutor.AbortPolicy());

        //第一个
        CompletableFuture<Integer> completableFuture01 =
                //提供一个线程的传值为100 ，并提供给线程池管理
                CompletableFuture.supplyAsync(()->100,
                executorService);
        //第一个
        CompletableFuture<Integer> completableFuture02 =
                CompletableFuture.supplyAsync(()->200,executorService);

        CompletableFuture<Integer> completableFuture03 = completableFuture01.thenComposeAsync((c2) ->completableFuture02, executorService);
        System.out.println(completableFuture03.get());
        executorService.shutdown();

    }
}
